package com.gjy.leetcode;

import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Map;

/**
 * 2325. 解密消息
 *
 * @author 宫静雨
 * @version 1.0
 * @since 2023-02-01 08:30:55
 */
public class A2325 {

    public String decodeMessage(String key, String message) {
        char[] chars = key.toCharArray();
        int original = 97;
        Map<Character, Character> map = new HashMap<>(40);
        for (char c : chars) {
            if (c != ' ') {
                if (!map.containsKey(c)) {
                    map.put(c, (char) original++);
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        char[] cs = message.toCharArray();
        for (char c : cs) {
            sb.append(map.getOrDefault(c, ' '));
        }
        return sb.toString();
    }

    @Test
    public void test2() {
        final byte a = 1, b = 2;
        byte i, k;
        i = a + b;
        k = (a + b);
        System.out.println(i);
    }

    @Test
    public void test1() {
        String key = "the quick brown fox jumps over the lazy dog";
        String s = decodeMessage(key, "vkbs bs t suepuv");
        System.out.println("s = " + s);
    }
}
